<!-- head -->
{include file='public/head' /}
<!-- head -->

<!-- left -->
{include file='public/left' /}
<!-- left -->

<div class="content-wrapper">
    <section class="content-header">
        <h1>
            店铺列表
            <small>审核通过</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 店铺管理</a></li>
            <li class="active">店铺列表</li>
        </ol>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-sm-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">共计{$storeList->total()}条记录</h3>
                        <div class="box-tools pull-right">
                            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                            </button>
                            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                        </div>
                    </div>
                    <div class="box-body">
                        <div class="table-responsive">
                            <table class="table table-bordered table-striped">
                                <form id='iform' action="{:url('Store/StoreList')}" method="get">
                                    <div class="input-group">
                                        <input type="text" name="store_name" value="{$store_name}" class="form-control" style="width: 20%;" placeholder="请输入店铺名...">
                                        <input type="text" name="phone" value="{$phone}" class="form-control" style="width: 20%;" placeholder="请输入负责人手机号...">
                                        <select class="form-control select2" style="width: 20%;" name="adminid">
                                            <option selected="selected" value="0">全部销售</option>
                                            {volist name='selladmin' id='selladmin'}
                                            {if condition="$selladmin['id'] eq $adminid"}
                                            <option value="{$selladmin.id}" selected>{$selladmin.admin_note}</option>
                                            {else/}
                                            <option value="{$selladmin.id}">{$selladmin.admin_note}</option>
                                            {/if}
                                            {/volist}
                                        </select>

                                        <select class="form-control select2" name="provdata" id='provdata' style="width: 10%;">
                                            <option value="0">请选择省份</option>
                                            {volist name='prov' id='prov'}
                                            {if condition="$prov['id'] eq $provdata"} 
                                            <option selected="selected" value="{$prov.id}">{$prov.name}</option>
                                            {else/}
                                            <option value="{$prov.id}">{$prov.name}</option>
                                            {/if}
                                            {/volist}
                                        </select>
                                        <select class="form-control select2" style="width: 10%;" name="level">
                                            <option value="0">请选择级别</option>
                                            <option value="1" {if condition='$level eq 1'} selected {/if}>体验版</option>
                                            <option value="2" {if condition='$level eq 2'} selected {/if}>标准版</option>
                                            <option value="3" {if condition='$level eq 3'} selected {/if}>专业版</option>
                                        </select>
                                        <div class="input-group date">
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>
                                            <input type="text" class="form-control pull-right" name="starttime" value="{$starttime}" id="datepicker" placeholder="选择开始时间..." autocomplete="off">
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>
                                            <input type="text" class="form-control pull-right" name="endtime" value="{$endtime}" id="datepicker1" placeholder="选择结束时间..." autocomplete="off">
                                        </div>
                                        <span class="input-group-btn">
                                            <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i></button>
                                            <!--<button type="button" class="btn btn-flat bg-olive" data-url="{:url('Store/storeExcel','','')}" onclick="storeExcel(this)"><i class="fa fa-download"></i></button>-->
                                        </span>
                                    </div>
                                </form>
                                <thead>
                                    <tr>
                                        <th>编号</th>
                                        <th>客户来源</th>
                                        <th>店名</th>
                                        <th>法人</th>
                                        <th>专属销售</th>
                                        <th>级别</th>
                                        <th>到期时间</th>
                                        <th>地区</th>
                                        <th>手机</th>
                                        <th>注册时间</th>
                                        <th>联系备注</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {volist name='storeList' id='admin'}
                                    <tr>
                                        <td>{$admin.id}</td>
                                        <td>
                                        {if condition="$admin.assign eq 0"}
                                        注册绑定
                                        {else/}
                                        <span style=" color: red">经理分配</span>
                                        {/if}
                                        </td>
                                        <td>{$admin.store_name}</td>
                                        <td>{$admin.store_keeper}</td>
                                        <td>{$admin.selladmin.admin_note}</td>
                                        <td>
                                        {if condition="$admin.level eq 1"}体验版
                                        {elseif condition="$admin.level eq 2"}标准版
                                        {elseif condition="$admin.level eq 3"}至尊版
                                        {elseif condition="$admin.level eq 4"}至尊版
                                        {/if}
                                        </td>
                                        <td>
                                        {if condition="$admin.expire_time eq ''"}
                                        ∞
                                        {else/}
                                        {$admin.expire_time|date="Y-m-d H:i:s",###}
                                        {/if}
                                        </td>
                                        <td>{$admin.prov_city_area.name}</td>
                                        <!--<td class="ord_phone">{$admin.keeper_phone}</td>-->
                                        <td><a href ="javascript:volid(0);" style="text-decoration: none;color: #000000;" title="{$admin.keeper_phone}" target='_blank' class="ord_phone">{$admin.keeper_phone}</a></td>
                                        <td>{$admin.add_time|date='Y-m-d H:i',###}</td>
                                        <td><input data-id="{$admin.id}" type="text" value="{$admin.msg}" class="form-control salesman"></td>
                                        <td style="width: 100px; text-align:right;">
                                            <button type="button" class="btn btn-sm bg-olive" data-url="{:url('selladmin/Store/ShowImgMessage',['id'=>$admin.id],'')}" onclick="ShowMessage(this)">查看信息 </button>&nbsp;
<!--                                            <button type="button" class="btn btn-sm btn-info" data-url="{:url('admin/Store/editStore',['id'=>$admin.id],'')}" onclick="edit(this)">修改</button>&nbsp;
                                            <button type="button" class="btn btn-sm btn-danger" onclick="del({$admin.id})">删除</button>
                                            <button type="button" class="btn btn-sm bg-orange" onclick="end({$admin.id})">下架体验卡</button>-->
                                        </td>
                                    </tr>
                                    {/volist}
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="box-footer clearfix" style="text-align: center">
                        {$storeList->render()}
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<script src="__STATIC__/AdminLTE/plugins/select2/select2.full.min.js"></script>

<script>
    $(function () {
        //Date picker
        $('#datepicker').datepicker({
            language:  'zh-CN',  
            autoclose: true,
        });
        $('#datepicker1').datepicker({
            language:  'zh-CN',  
            autoclose: true
        });
    });
</script>
<script type="text/javascript">
    $(function(){
    var ord_phone = $(".ord_phone");
    for (var i = 0; i < ord_phone.length; i++){
        var cnd = $(".ord_phone").eq(i).text();
        var mpcnd = cnd.substr(0, 3) + '****' + cnd.substr(7);
        $(".ord_phone").eq(i).text(mpcnd);
    }

    });
    var dataId = 0;
    function edit(obj) {
    var url = $(obj).data('url');
    window.location.href = url;
    }
    function ShowMessage(obj) {
    var url = $(obj).data('url');
    window.location.href = url;
    }
    function storeExcel(obj) {
    var url = $(obj).data('url');
    var provdata = window.document.getElementById('provdata').value;
    var starttime = window.document.getElementById('datepicker').value;
    var endtime = window.document.getElementById('datepicker1').value;   
    if(starttime){
        starttime=new Date(starttime);
        starttime=starttime.getTime(starttime)/1000;
    }else{
        starttime=0;
    }
    if(endtime){
        endtime=new Date(endtime);
        endtime=endtime.getTime(endtime)/1000;
    }else{
        endtime=0;
    }
    window.location.href = url + '/prov/' + provdata+'/starttime/'+starttime+'/endtime/'+endtime;
    }

    function del(id) {
    dataId = id;
    showConfirm('删除', '确认删除？', delManager);
    }

    function delManager() {
    $.ajax({
    url: "{:url('admin/Store/DelStore','','')}",
            type: 'GET',
            data: {
            'id': dataId,
            },
            dataType: 'JSON',
            success: function(data) {
            showAlert('提示', data.msg, null);
            if (data.code == 1) {

            }
            }
    });
    }


    function end(id) {
    dataId = id;
    showConfirm('体验卡下架', '请确认已经和商家沟通过？', delExper);
    }

    function delExper() {
    $.ajax({
    url: "{:url('admin/Store/EndExpercard','','')}",
            type: 'GET',
            data: {
            'id': dataId,
            },
            dataType: 'JSON',
            success: function(data) {
            showAlert('提示', data.msg, null);
            if (data.code == 1) {

            }
            }
    });
    }


    $(".salesman").each(function () {
    $(this).change(function () {
    var inputval = $(this).val();
    var id = $(this).attr('data-id');
    $.ajax({
    url: "{:url('Store/SaveMsg','','')}",
            type: 'POST',
            data: {
            'id': id,
                    'msg': inputval,
            },
            dataType: 'JSON',
            success: function (data) {
            }
    });
    })
    });
</script>

<!-- foot -->
{include file='public/foot' /}
<!-- foot -->